package com.android.dumiaogou.fragment.group;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.android.dumiaogou.R;
import com.android.dumiaogou.adapt.ListDetailCommentAdapt;
import com.android.dumiaogou.fragment.BaseLazyFragment;
import com.android.dumiaogou.utils.ObjectUtils;
import com.mcxtzhang.nestlistview.NestFullListView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/9/2.
 */

public class Fragment_OrderToShare extends BaseLazyFragment {

    @BindView(R.id.ll_orderdetail_goods_img)
    ImageView ll_orderdetail_goods_img;
    @BindView(R.id.ll_orderdetail_goods_title)
    TextView ll_orderdetail_goods_title;
    @BindView(R.id.ll_orderdetail_goods_price)
    TextView ll_orderdetail_goods_price;
    @BindView(R.id.ll_content_edit)
    EditText ll_content_edit;
    @BindView(R.id.item_item_detail_comment_star)
    RatingBar item_item_detail_comment_star;
    @BindView(R.id.order_grid_sort)
    NestFullListView order_grid_sort;
    private FragmentActivity mcontext;
    private View view;
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    private static final String ARG_PARAM3 = "param3";
    private static final String ARG_PARAM4 = "param4";
    private String need_id;
    String order_thumbs ;
    String order_title;
    String order_price;
    private boolean networkConnected;
    private int page = 1;
    private ListDetailCommentAdapt adapter;

    public Fragment_OrderToShare() {

    }

    public static Fragment_OrderToShare newInstance(String need_id,String order_thumbs,String order_title,String order_price) {
        Fragment_OrderToShare fragment = new Fragment_OrderToShare();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1,need_id);
        args.putString(ARG_PARAM2,order_thumbs);
        args.putString(ARG_PARAM3,order_title);
        args.putString(ARG_PARAM4,order_price);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            need_id = getArguments().getString(ARG_PARAM1);
            order_thumbs = getArguments().getString(ARG_PARAM2);
            order_title= getArguments().getString(ARG_PARAM3);
            order_price= getArguments().getString(ARG_PARAM4);
        }
    }


    @Override
    protected void initPrepare() {

    }

    private void init() {
        ObjectUtils.photo2(mcontext,order_thumbs,ll_orderdetail_goods_img);
        ll_orderdetail_goods_title.setText(order_title);
        ll_orderdetail_goods_price.setText(order_price);
    }

    @Override
    protected void onInvisible() {

    }


    @Override
    protected void initData() {


    }


    @Override
    protected View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_ordertoshare, container, false);
        mcontext = getActivity();
        ButterKnife.bind(this, view);
        init();
        return view;
    }


    @OnClick({R.id.release})
    public void onClick(View view) {
        switch (view.getId())
        {

            case R.id.release:
                String content = ll_content_edit.getText().toString().trim();
                if(content==null&&content.equals(""))
                {
                    ObjectUtils.toast(mcontext,"请输入分享内容");
                    return;
                }
                int rate = item_item_detail_comment_star.getNumStars();
                if(rate==0)
                {
                    ObjectUtils.toast(mcontext,"请输入评分");
                    return;
                }

                break;
        }
    }
}